articles

Home / DeveloperSection / Articles / LinkLabel Control in C#.Net

LinkLabel Control in C#.Net

LinkLabel Control in C#.Net

Anonymous User 23537 24-Jan-2011

LinkLabel is a class that is derived from label class so it has all the functions of label class. But LinkLabel control works as a hyperlink and its appearance is also a hyperlink.

Drag and drop LinkLabel control from the toolbox on the window Form.

LinkLabel Control in C#.Net

Code:

Write code on LinkClicked event

LinkLabel Control in C#.Net

private void linkLabel1_LinkClicked(object sender,  LinkLabelLinkClickedEventArgs e)
{
//after visiting site LinkLabel color changed which will indicate  that you have visited this site
        linkLabel1.LinkVisited = true;
        System.Diagnostics.Process.Start("www.mindstick.com");
        //using the start method of system.diagnostics.process class
        //process class gives access to local and remote processes
 }
System.Diagnostics.Process.Start

The System. The Diagnostics namespace exposes a Process class that you can use to launch external programs. We can launch a new process with the shared Process. The Start method, passing it either the name of an executable file or a filename with an extension associated with an executable application.

Run the project

LinkLabel Control in C#.Net

When you click on the link Go to google then the LinkClicked event will fire and redirected to www.google.com.

LinkLabel Control in C#.Net

LinkLabel Properties:

LinkBehaviour: The behavior of link can be changed through LinkBehaviour properties LinkLabel.

Example:

private void Form9_Load(object sender, EventArgs e)
{
  //disable underline
  linkLabel1.LinkBehavior = LinkBehavior.NeverUnderline;
}


LinkLabel Control in C#.Net

Now when the application runs then Underline will not show in LinkLabel.

ForeColor:  set the foreground color of the LinkLabel control.

BackColor:  set the background color of LinkLabel control.


Example:
private void Form9_Load(object sender, EventArgs e)
{
        //change BackColor of LinkLabel
        linkLabel1.BackColor = Color.CadetBlue;
}


LinkLabel Control in C#.Net

 


c# c# 
Updated 04-Mar-2020
I am a content writter !

Leave Comment

Comments

Liked By